#ifndef CATALOGUELOADER_H__
#define CATALOGUELOADER_H__

#include "ProjectHeader.h"

class CatalogueLoader
{
public:

	// Returns: 0 if successful. Error returns: an error value from ERROR_ENUM - NULL_FILE_ERROR, TEX_LOAD_ERROR
	//Loads up texture atlases; Should be passed the filename of a catalogue file.
	static int LoadTextureAtlases(const char *, const TextureLoader_delegate, std::map<int, texCoord2f>&);
	//Passed  in: the address of the catalogue file, fastDelegate for texture loading
	//Passed out: int error code, map of textures loaded (by reference)

	static int LoadScene(const char *, std::vector<std::vector<CUBE_PROTO_INDEX>>&, std::map<int, Cube_Prototype>&, GLfloat&); 
	//Passed  in: the address of the catalogue file
	//Passed out: int error code, vector[][] cube map (by reference), vector of cube prototypes (by reference), grid spacing (by reference)

private:

	// Return values: Substring extracted from string& passed. No error returns.
	static std::string GetSubStr(std::string&, const char);
	// Helper function; returns a substring from the first character of a string to the one before the first seperator character. 
	// Also removes this substring from the string passed, as well as the seperator and any whitespace following it.

	// Return Values: None; String passed by reference. No error returns.
	static void TrimString(std::string&);
	 //Helper function; trims off all the whitespace from the start of the string passed - both spaces and tabs.

	static int TaiParser(const std::vector<std::string>&, std::map<std::string, int>&, std::map<int, texCoord2f>&, const TextureLoader_delegate);
	//Note: the TexID parameter isn't passed as const because the elements are removed one by one. It will be empty when the function returns,
	//if all went well.

	static int CatParser(const char *);

	static int ScnParser(const char *, const std::map<int, Cube_Prototype>&, std::vector<std::vector<CUBE_PROTO_INDEX>>&);

	static GLfloat static_GridSpace;
	static std::string SceneFile;
	static std::string LastCatalogue;					//Holds the address of the last catalogue loaded; Stops CatParser running unneededly.
	static std::map<std::string, int> static_TexIDs;	//TexIDs generated by CatParser for the last file opened
	static std::vector<std::string> static_TaiFiles;	//TaiFiles generated by CatParser for the last file opened
	static std::map<int, Cube_Prototype> static_Cubes;	//Holds cube prototypes generated by CatParser for the last file opened.

};
#endif